# -*- coding: utf-8 -*-
'''
Created on 2020/1/2 20:33 
author:dyx
IDE:PyCharm 
'''

import numpy as np
import random
'''
t1 = np.array([1,2,3,])
print(t1)
print(type(t1))
print(t1.dtype)

#使用numpy生成数组得到array的类型
t2 = np.array(range(10))
print(t2)
print(type(t2))
print(t2.dtype)

t3 = np.arange(10)
print(t3)
print(type(t3))
print(t3.dtype)

#numpy中的数据类型
t4 = np.array(range(1,4),dtype="int64")
print(t4)
print(t4.dtype)

#numpy中的bool类型
t5 = np.array([1,1,0,1,0,0],dtype = bool)
print(t5)
print(t5.dtype)

#调整数据类型
t6 = t5.astype("int8")
print(t6)
print(t6.dtype)

#numpy中的小数
t7 = np.array([random.random() for i in range(10)])
print(t7)
print(t7.dtype)

t8 = np.round(t7,3)#取小数
print(t8)
print(t8.dtype)
'''

#数组的形状
t1 = np.arange(12)
print(t1)
print(t1.shape)

t2 = np.array([[1,2,3,4],[5,6,7,8]])
print(t2)
print(t2.shape)

t3 = np.array([[[1,2,3],[4,5,6]],[[7,8,9],[10,11,12]]])
print(t3)
print(t3.shape)

t4 = np.arange(12)
t4 = t4.reshape((3,4))
print(t4)

t5 = np.arange(24).reshape((2,3,4))
print(t5)

t6 = t5.reshape((4,6))
print(t6)

t7 = t6.reshape((24,))
print(t7)

print(t6)
t8 = t6.reshape((t6.shape[0] * t6.shape[1],))
print(t8)
t8 = t6.flatten()#把多维数组展开
print(t8)

